package com.ztt.main;

import java.io.File;

import com.ztt.Config;
import com.ztt.model.ProductDetailsModel;
import com.ztt.service.AnalyticalDataGoodsService;

/**
 * 爬虫数据抓取测试
 * 
 * @author apple
 * 
 */
public class CrawlerTest {
	
	public static void main(String[] args) {
		//进行数据抓取
		//http://www.taocz.com/combination-8259.html
		//http://www.taocz.com/goods-447265.html
		//http://www.taocz.com/goods-347885.html
		String mUrl = "http://www.taocz.com/goods-347885.html";
		ProductDetailsModel mProductDetailsModel=null;
		 mUrl = "http://www.taocz.com/goods-347885.html";
		//进行文件存放目录创建
		createDirectory();
		if(mUrl.startsWith("http://www.taocz.com/combination-")){
			
		}else if(mUrl.startsWith("http://www.taocz.com/goods-")) {
			AnalyticalDataGoodsService mAnalyticalDataService = new AnalyticalDataGoodsService(
					mUrl);
			try {
				//进行数据抓取
				mProductDetailsModel=mAnalyticalDataService.getDataService();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
	}
	/**
	 * 进行本地服务器 文件存放地址 路径目录
	 */
	public  static void createDirectory() {
		File rootPath = new File(Config.ROOT_PATH);
		if (!rootPath.exists()) {
			rootPath.mkdirs();
		}
		if (rootPath.exists()) {
			File image_directory = new File(rootPath, Config.IMAGE_DIRECTORY);
			if (!image_directory.exists()) {
				image_directory.mkdirs();
			}
		}
	}
}
